<!DOCTYPE html>
<html>
  <head>
    <title>Logbot | #<%= @channel %></title>
    <link rel="stylesheet" type="text/css" href="/assets/screen.css">
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ropa+Sans">
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans+Mono">
    <base target="_blank" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  </head>
  <body>
    <div class="wrapper">
      <div class="header">
        <h1>OSINT IRC MODULE</h1>
      </div>
      <div class="quick-nav">
        <div class="nav_page-up" onclick="pageScrollTop(0);">⬆</div>
        <div class="nav_page-down" onclick="pageScrollTop($(document).height());">⬇</div>
      </div>
      <div class="body">
        <div class="channel">#<%= @channel %></div>
        
        <% given_date = Time.parse(@date) %>
        <select id="date-picker" class="date">
          <% if (Time.now - given_date > 86400 * 5) %>
            <option value="<%= @date %>"><%= @date %></option>
          <% end %>
          <optgroup label="Today">
            <option value="today" <%= "selected" if @date == Date.today.to_s %>><%= Date.today.to_s %></option>
          </optgroup>
          <optgroup label="Earlier logs">
            <% (1.upto 4).map{|d| (Date.today - d).to_s }.each do |date| %>
              <option value="<%= date %>" <%= "selected" if @date == date %>><%= date %></option>
            <% end %>
          </optgroup>
        </select>

        <div class="scroll_switch">AUTO⬇ </div>
       
        <div>
          <ul class="logs">
            <% @msgs.each do |msg| %>
              <% linked_msg = msg["msg"].gsub(/http[s]*:\/\/[^\s]+/, '<a href="\0">\0</a>') %>
              <li>
                <span class="time"><%= Time.at(msg["time"].to_f).strftime("%T") %></span>
                <span class="nick"><%= msg["nick"] %></span>
                <span class="msg wordwrap"><%= linked_msg %></span>
              </li>
            <% end %>
          </ul>
        </div>
      </div>
      <div class="footer">
        <p>Powered by Logbot 2013 | <a href="https://github.com/dannvix/Logbot">GitHub Repo</a></p>
      </div>
    </div>
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    <script>
      var channel = "<%= @channel %>";
    </script>
    <script src="/assets/applications.js"></script>
    <% if @date == Date.today.to_s %>
      <script>pollNewMsg();</script>
    <% end %>
  </body>
</html>
